package guavaTest.preConditions;

import com.google.common.base.Preconditions;

import java.util.List;

/**
 * 先决条件
 */
public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        List list = null;
        main.getArrItem(new String[]{"12"},1);
        main.getListItem(list);
        main.division(1,0);
    }

    //除法
    public int division(int a,int b){
        //检查参数是否满足预期表达式 提前
        Preconditions.checkArgument(b!=0,"被除数不能为0",a,b,1,2,3);
        return a/b;
    }

    public int getListItem(List list ){
        Preconditions.checkNotNull(list ,"值不能为NULL");
        return 0;
    }

    public int getArrItem(String[] x,int index){
        Preconditions.checkElementIndex(index,x.length,"数组长度过长");
        return 0;
    }





}
